#include<cstdio>//uncle-lu
#include<cstring>
#include<algorithm>

char a[2010], b[2010];
int F[2010][2010];

int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	int len_a = strlen(a+1), len_b = strlen(b+1);

	memset(F, 0x7f7f7f, sizeof(F));
	F[0][0] = 0;
	for (int i = 1; i <= len_a; i++) 
		F[i][0] = i;
	for (int i = 1; i <= len_b; i++) 
		F[0][i] = i;

	for (int i = 1; i <= len_a; i++) 
	{
		for (int j = 1; j <= len_b; j++) 
		{
			if(a[i] == b[j])
				F[i][j] = F[i-1][j-1];
			else
				F[i][j] = std::min(std::min(F[i-1][j], F[i][j-1]), F[i-1][j-1]) + 1;
		}
	}

	printf("%d", F[len_a][len_b]);
	return 0;
}
